package com.hbnu.controller;

import com.hbnu.pojo.OTD.Result;
import com.hbnu.pojo.Pet;
import com.hbnu.pojo.Server;
import com.hbnu.service.ServerService;
import com.hbnu.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/server")
public class ServerController {
    @Autowired
    private ServerService ServerService;
    @Autowired
    private PetService PetService;

    //获取当前宠物预约信息
    @GetMapping("/mine")
    public Result getMyPets(@RequestParam Integer userId) {
        List<Pet> pets = PetService.getPetsByOwnerId(userId);
        return Result.success(pets);
    }
    //添加预约服务
    @GetMapping("/serveradd")
    public Map<String, Object> addServer(@RequestBody Server server){
        boolean success = ServerService.addServer(server);
        Map<String, Object> res  = new HashMap<>();
        res.put("success",  success);
        res.put("message", success ? "添加成功" : "添加失败");
        return res;
    }


}
